package com.web.common;

import lombok.Data;



//@Data
//public class Result<T> {
//    private Integer code;
//    private String message;
//    private T data;
//
//    public static <T> Result<T> success() {
//        return success(null);
//    }
//
//
//    public static <T> Result<T> success(T data) {
//        Result<T> result = new Result<>();
//        result.setCode(200);
//        result.setMessage("操作成功");
//        result.setData(data);
//        return result;
//    }
//
//    public static <T> Result<T> error(String message) {
//        Result<T> result = new Result<>();
//        result.setCode(500);
//        result.setMessage(message);
//        return result;
//    }
//
//    public static <T> Result<T> error(Integer code, String message) {
//        Result<T> result = new Result<>();
//        result.setCode(code);
//        result.setMessage(message);
//        return result;
//    }
//}

@Data
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> Result<T> success(String msg, T data) {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> success(String msg) {
        return success(msg, null);
    }

    public static <T> Result<T> fail(String msg) {
        Result<T> result = new Result<>();
        result.setCode(400);
        result.setMsg(msg);
        return result;

    }
}